package biz.common.service;


import biz.master.dto.Area;
import biz.master.dto.Branch;
import biz.master.dto.Location;
import biz.master.dto.Warehouse;
import glen.util.BaseSvr;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


public class ProdLocationSvr extends BaseSvr {

    public ProdLocationSvr() {
        super("ProdLocation");

    }

    public List<Area> searchArea(Area o) {
        List<Area> list;

        try (SqlSession session = sf.openSession()) {
            String query = "ProdLocation.searchArea";

            list = session.selectList(query, o);

        }
        return list;
    }

    public List<Branch> searchBranch(Branch o) {
        List<Branch> list;

        try (SqlSession session = sf.openSession()) {
            String query = "ProdLocation.searchBranch";

            list = session.selectList(query, o);

        }
        return list;
    }

    public List<Branch> searchBranchByArea(int areaId) {

        List<Branch> list;

        try (SqlSession session = sf.openSession()) {
            String query = "ProdLocation.searchBranchByArea";

            list = session.selectList(query, areaId);

        }
        return list;
    }

    public List<Warehouse> searchWarehouseByBranch(int branchId) {

        List<Warehouse> list;

        try (SqlSession session = sf.openSession()) {
            String query = "ProdLocation.searchWarehouseByBranch";

            list = session.selectList(query, branchId);

        }
        return list;
    }

    public List<Location> searchLocationByWarehouse(int warehouseId) {

        List<Location> list;

        try (SqlSession session = sf.openSession()) {
            String query = "ProdLocation.searchLocationByWarehouse";

            list = session.selectList(query, warehouseId);

        }
        return list;
    }

}
